// FIGURES

use "${filedata}for_regs.dta", clear

gegen m_all_female=mean(all_female), by(class)
replace m_all=m_all*10

gen T=.
rename top50_atty top50
replace Female=all_female
replace iv=iv_initial

egen rank =rank(filing_date),by(ee_name_disambig)
replace rank=. if ee_name_disambig==""
sinh rank


foreach i in emp_assigned lrank lawyer top50 m_all   { 
	
	replace T=`i'

ivreghdfe initial_amendment  ///
			(c.Female#c.initial_rejection#c.T  c.initial_rejection#c.T  c.Female#c.initial_rejection ///
			initial_rejection = c.Female#c.iv#c.T c.Female#c.iv c.T#c.iv iv) ///
			Female T c.Female#c.T ///
			inventor_count prev_apps prev_pats min_years pub_clm_ct pub_wrd_ct pub_wrd_min pub_dep_clm_ct 	pub_dep_wrd_ct pub_dep_wrd_min pub_wrd_avg pub_dep_wrd_avg  ///  
m_pub_clm_ct m_prev_pats m_min_years ///
			, a(art_year) cluster(examiner_year)		
	eststo i_`i'	

ivreghdfe patent_issued  ///
			(c.Female#c.initial_rejection#c.T c.initial_rejection#c.T c.Female#c.initial_rejection ///
			initial_rejection = c.Female#c.iv#c.T c.Female#c.iv c.T#c.iv iv) ///
			Female T c.Female#c.T ///
			inventor_count prev_apps prev_pats min_years pub_clm_ct pub_wrd_ct pub_wrd_min pub_dep_clm_ct 	pub_dep_wrd_ct pub_dep_wrd_min pub_wrd_avg pub_dep_wrd_avg  ///  
m_pub_clm_ct m_prev_pats m_min_years ///
, a(art_year) cluster(examiner_year) 			
	eststo p_`i'
}

set level 90

coefplot (i_emp_assigned, label("Employer")) (i_lrank, label("(ln) Experience")) (i_lawyer,label("Has  Lawyer")) (i_top50,label("Top 50 Lawyer"))  ///
			(i_m_all, label("Female Share in Class")) ,keep(c.Female#c.initial_rejection#c.T ) xsc(r(-.02 .08)) xlabel(-0.04 -0.02 0 0.02 0.04 0.06 0.08 0.1 ) ylabel(#7)  legend(off)  ///
			xline(0)  bycoef xtitle("Triple Interaction: Initial Rejection {c 215} Female {c 215} Institutional Support" "(Five Separate Regressions)")  ///
			ytitle("")graphregion(color(white)) scheme(sj) ylabel(,nolabels)
			
graph export "${results}mechanism_ia_fig.pdf",replace 


coefplot (p_emp_assigned, label("Employer")) (p_lrank, label("(ln) Experience")) (p_lawyer,label("Has Lawyer")) (p_top50,label("Top 50 Lawyer"))  ///
				(p_m_all, label("Female Share in Class")) ,keep(c.Female#c.initial_rejection#c.T ) xsc(r(-.02 .14)) xlabel(#10) ylabel(#7)   ///
			xline(0)  bycoef xtitle("Triple Interaction: Initial Rejection {c 215} Female {c 215} Institutional Support" "(Five Separate Regressions)")  ///
			ytitle("")graphregion(color(white)) scheme(sj) ylabel(,nolabels)
graph export "${results}mechanism_pg_fig.pdf",replace





		
